package com.eastfair.tag;

import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
import com.eastfair.log.LampMdcAdapterInitializer;
import com.eastfair.security.annotation.EnableLoginArgResolver;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;

import static com.eastfair.constant.BizConstant.UTIL_PACKAGE;


/**
 * 标签：
 * 1 标签和标签层级生成（包含分类标签）  √
 * 2 标签与事件绑定 √
 * 3 标签与行为条件绑定 √
 * 4 标签与选项绑定
 * 5 目标存mongo
 * 6 标签分类各种查询
 * 7 标签目标查询
 */
@SpringBootApplication(exclude = DruidDataSourceAutoConfigure.class)
@Configuration
@ComponentScan({
        UTIL_PACKAGE
})
@Slf4j
@EnableAspectJAutoProxy(proxyTargetClass = true, exposeProxy = true)
@MapperScan("com.eastfair.tag.dao")
@EnableDiscoveryClient
@EnableLoginArgResolver
@EnableFeignClients({UTIL_PACKAGE})
public class TagApplication {
    public static void main(String[] args) throws UnknownHostException {
        SpringApplication application = new SpringApplication(TagApplication.class);
        application.addInitializers(new LampMdcAdapterInitializer());
        ConfigurableApplicationContext applicationContext = application.run(args);


        Environment env = applicationContext.getEnvironment();
        log.info("\n----------------------------------------------------------\n\t" +
                        "应用 '{}' 运行成功! 访问连接:\n\t" +
                        "Swagger文档: \t\thttp://{}:{}/doc.html\n\t" +
                        "数据库监控: \t\thttp://{}:{}/druid\n" +
                        "----------------------------------------------------------",
                env.getProperty("spring.application.name"),
                InetAddress.getLocalHost().getHostAddress(),
                env.getProperty("server.port"),
                "127.0.0.1",
                env.getProperty("server.port"));
    }

}
